<template>
	<view class="form_index">
		<view v-for="(item,index) in params.list" :key="index">
			<ABlogCard :isfollow="true" :item="item"></ABlogCard>
		</view>
		<view v-if="params.list.length==0" class="empty_container">
			<u-empty text="暂无浏览记录" mode="data" width="100%" iconSize="60" textSize="32"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		getforward
	} from '@/api/forum.js'
	export default {
		props: ['refresh'],
		watch: {
			'refresh': {
				handler(val) {
					if (val) {
						this.pageParams.pageNum = 1
						this.getList(this.pageParams, false)
					}
				}
			}
		},
		mounted() {
			this.getList(this.pageParams)
			uni.$on('onBottom', () => {
				if (this.params.list.length !== this.params.total) {
					this.pageParams.pageNum += 1
					this.getList(this.pageParams)
				}
			})
		},
		data() {
			return {
				params: {
					list: [],
					total: 0
				},
				pageParams: {
					pageNum: 1,
					pageSize: 5
				}
			}
		},
		methods: {
			getList(data, flag = true) {
				if (flag) {
					getforward(data).then(res => {
						console.log(res);
						this.params.total = res.data.total
						this.params.list = this.params.list.concat(res.data.list)
					})
				} else {
					getforward(data).then(res => {
						console.log(res);
						this.params.total = res.data.total
						this.params.list = res.data.list
					})

				}

			}
		},

	}
</script>

<style lang="scss">
	.form_index{
		margin-top: -70rpx;
	}
	.empty_container {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 60vh;
	
		.u-empty {
			height: 60vh;
		}
	}
</style>